/* ====================================================================
 * (#)Header: PropertyComparator.java
 * (#)Revision: 
 * (#)Date Created: Mar 2, 2007 12:07:22 AM
 * (#)Created By: Karol Wozniak
 * ====================================================================
 *
 * Copyright (c) 2007 karolak .  All rights reserved.
 *
 * ====================================================================
 * 
 * The software application represented here is the sole property of 
 * karolak. Its unauthorized utilization is expressly prohibited.
 * 
 * ====================================================================
 */
package com.karolak.bean;

import java.lang.reflect.Method;
import java.util.Comparator;

/**
 * <code>PropertyComparator</code> is used to ....
 * 
 * @author <a href="mailto:kwozniak@hotmail.com">Karol Wozniak</a>
 */
public class PropertyComparator<T> implements Comparator<T> {

	private Method[] propertyAccessors;

	public PropertyComparator(Class<?> clazz, String... propertyNames) {
		this.propertyAccessors = BeanUtils.getPropertyAccessors(clazz, propertyNames);
	}

	public int compare(T o1, T o2) {
		return ComparatorUtils.compare(o1, o2, propertyAccessors);
	}
}
